home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / misc / nnn.lha / nnn1.35 / src / Neural.h < prev    next >
C/C++ Source or Header  |  1995-08-29  |  4KB  |  149 lines

  1. /*
  2.  *  $Id: Neural.h 1.14 1995/08/29 23:16:05 daltern Exp $
  3.  *
  4.  *  This is the general header file for the program nnn and its
  5.  *  associated functions.
  6.  *
  7.  */
  8.  
  9. /*========================================================================*
  10.                 INCLUDES
  11.  *========================================================================*/
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <math.h>
  16. #include <string.h>
  17. #include <signal.h>
  18.  
  19. /*
  20.  *  Amiga specific includes
  21.  */
  22.  
  23. #ifdef _AMIGA
  24.  
  25. #include <dos.h>
  26.  
  27. #endif
  28.  
  29. /*========================================================================*
  30.                 DEFINITIONS
  31.  *========================================================================*/
  32.  
  33. #define     TRUE        1
  34. #define     FALSE        0
  35.  
  36. #define     RAND_FUNC    drand48
  37. #define     SEED_FUNC    srand48
  38.  
  39. #define     NUM_RAND_STEPS    20
  40.  
  41. #define     HIGH_STATE    1
  42. #define     LOW_STATE    0
  43.  
  44. #define     MAXCHAR     100
  45. #define     MAX_VECS    1000
  46. #define     MAX_ITS     10000
  47.  
  48. #define        USER_UPDATE    50
  49.  
  50. static char *DELIMITER[] = {
  51. "#Weights",             /* Start of section storing ANN weights          */
  52. "#Vectors",             /* Start of section storing input vectors        */
  53. "#Layers"               /* Start of layer size info                      */
  54. };
  55.  
  56. /*========================================================================*
  57.                 DATA TYPES
  58.  *========================================================================*/
  59.  
  60.     struct    Vectors {
  61.  
  62.             int    NumVecs;
  63.             float    **InVec;
  64.             float    **OutVec;
  65.  
  66.             };
  67.  
  68.     typedef struct Vectors VECTOR;
  69.  
  70.  
  71.     struct    Net    {
  72.  
  73.             int    NumLayers;
  74.             int    *LayerSize;
  75.  
  76.             };
  77.  
  78.     typedef struct    Net NET;
  79.  
  80. /*=========================================================================*
  81.                  PROTOTYPES
  82.  *=========================================================================*/
  83.  
  84.     extern    float    NetTransFunc( float,float );
  85.     extern    void    NetFeedForward( float ***,float **,NET,float );
  86.     extern    void    NetBackProp( float ***,float ***,float **,NET,float *,float,float,float );
  87.     extern    void    NetWriteConfig( NET,VECTOR,float ***,float,float,float,float,float,float );
  88.     extern    void    NetVecRand( VECTOR * );
  89.         extern    void    NetExit( NET *,VECTOR *,float **, float ***,float *** ); 
  90.     extern    void    NetAbort( int );
  91.     extern    double    drand48( void );
  92.     extern    void    srand48( long );
  93.  
  94. /*=========================================================================*
  95.                  END OF NEURAL.H
  96.  *=========================================================================*/
  97.  
  98. /*
  99.  *  $Id: Neural.h 1.14 1995/08/29 23:16:05 daltern Exp $
  100.  *
  101.  *  This header file defines some macros for array allocation
  102.  *  and deallocation.
  103.  * 
  104.  */
  105.  
  106. /*
  107.  *  NOTE requires i,j and array to be defined in program
  108.  */
  109.  
  110. #define  MAKE1D(array,type,rows) {\
  111.          array = (type *)malloc(rows * sizeof(type)); \
  112. }
  113.  
  114. #define  MAKE2D(array,type,rows,cols) {\
  115.          array  = (type **)malloc(rows * sizeof(type *)); \
  116.          for (i = 0; i < rows; i++) \
  117.              array[i] = (type *)malloc(cols * sizeof(type)); \
  118. }
  119.  
  120. #define     MAKE3D(array,type,depth,rows,cols) {\
  121.      array = (type *** )malloc(depth * sizeof(type **));\
  122.      for ( i = 0; i < depth; i++ ) {\
  123.          array[i] = (type **)malloc(rows * sizeof(type *));\
  124.          for ( j = 0; j < rows; j++ )\
  125.                  array[i][j] = (type *)malloc(cols * sizeof(type));\
  126.          }\
  127. }
  128.     
  129. #define  FREE3D(array,depth,rows) {\
  130.      for( i = 0; i < depth; i++ ) {\
  131.          for ( j = 0; j < rows; j++ )\
  132.             free(array[i][j]);\
  133.         free(array[i]);\
  134.      }\
  135.      free(array);\
  136. }
  137.  
  138. #define  FREE2D(array,rows) {\
  139.          for(i = 0; i < rows; i++) \
  140.                 free(array[i]); \
  141.      free(array);\
  142. }
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.